<template>
    <div class="centermap">
        <div class="maptitle">
            <div class="zuo"></div>
            <span class="titletext">{{ title }}</span>
            <div class="you"></div>
        </div>
        <div class="mapwrap">
            <BorderBox13>
                <div class="quanguo">刷新</div>
                <div class="box-main">
                    <div style="padding: 60px;">
                        <el-row :gutter="20">
                        <el-col :span="6">
                            <div class="grid-content ep-bg-purple">
                                <h3 style="text-align: center;">当前订单</h3>
                                <p>{{state.orderCode}}</p>
                            </div>
                        </el-col>
                        <el-col :span="6">
                            <div class="grid-content ep-bg-purple">
                                <h3 style="text-align: center;">整线OEE</h3>
                                <p>{{ state.oee }}%</p>
                            </div>
                        </el-col>
                        <el-col :span="6">
                            <div class="grid-content ep-bg-purple">
                                <h3 style="text-align: center;">总运行时间</h3>
                                <P>{{state.totalTime}}min</P>
                            </div>
                        </el-col>
                        <el-col :span="6">
                            <div class="grid-content ep-bg-purple">
                                <h3 style="text-align: center;">故障时间</h3>
                                <P>{{state.mtbf}}min</P>
                            </div>
                        </el-col>
                    </el-row>
                    </div>
                    
                </div>

            </BorderBox13>
        </div>
    </div>
</template>
<script setup lang="ts">
import { centerTop } from "@/api";
import BorderBox13 from "@/components/datav/border-box-13";
import { ElMessage } from "element-plus";
import { reactive, ref ,onMounted} from "vue";
import CountUp from "@/components/count-up";
withDefaults(
    defineProps<{
        title: number | string;
    }>(),
    {
        title: "刷新",
    }
);
const duration = ref(2);
const state = reactive({
    orderCode: '',
    oee: 0,
    totalTime: 0,
    mtbf: 0,
});
const getData = () => {
  centerTop()
    .then((res) => {
      console.log("中上--设备分布", res);
      if (res.code==200) {
        state.orderCode=res.data.orderCode
        state.oee=res.data.oee
        state.totalTime=res.data.totalTime
        state.mtbf=res.data.mtbf
      console.log("中上--设备分布", state);

      } else {
        ElMessage.error(res.msg);
      }
    })
    .catch((err) => {
      ElMessage.error(err);
    });
};
onMounted(() => {
  getData();
  let timer = null;
  timer = setInterval(() => {
    getData();
  }, 10000);
});
</script>
<style lang="scss">
element.style {
    margin: 0 !important;
}

.box-main {
    width: 100%;
    height: 100%;
    text-align: center;
}

.el-row {
    margin-bottom: 20px;
}

.el-row:last-child {
    margin-bottom: 0;
}

.el-col {
    border-radius: 4px;
}

.grid-content {
    border-radius: 4px;
    min-height: 36px;
    border: 1px solid #0072ff;
}

.centermap {
    margin-bottom: 30px;
    overflow: hidden;
    .maptitle {
        height: 60px;
        display: flex;
        justify-content: center;
        padding-top: 10px;
        box-sizing: border-box;

        .titletext {
            font-size: 28px;
            font-weight: 900;
            letter-spacing: 6px;
            background: linear-gradient(92deg, #0072ff 0%, #00eaff 48.8525390625%, #01aaff 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin: 0 10px;
        }

        .zuo,
        .you {
            background-size: 100% 100%;
            width: 29px;
            height: 20px;
            margin-top: 8px;
        }

        .zuo {
            background: url("@/assets/img/xiezuo.png") no-repeat;
        }

        .you {
            background: url("@/assets/img/xieyou.png") no-repeat;
        }
    }

    .mapwrap {
        height: 250px;
        width: 100%;
        // padding: 0 0 10px 0;
        box-sizing: border-box;
        position: relative;

        .quanguo {
            position: absolute;
            right: 20px;
            top: -46px;
            width: 80px;
            height: 28px;
            border: 1px solid #00eded;
            border-radius: 10px;
            color: #00f7f6;
            text-align: center;
            line-height: 26px;
            letter-spacing: 6px;
            cursor: pointer;
            box-shadow: 0 2px 4px rgba(0, 237, 237, 0.5), 0 0 6px rgba(0, 237, 237, 0.4);
            z-index: 10;
        }
    }
}
</style>